package br.com.utils;

import java.sql.Date;
import java.sql.Time;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

public class FormatUtils {


	private Date data;
	
	private String dataString;

	public Date getData() {
		return data;
	}

	public static Date setData(String data) throws Exception {

		java.sql.Date date = null;
		try {
			DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
			date = new java.sql.Date(((java.util.Date) formatter.parse(data)).getTime());
		} catch (ParseException e) {
			throw e;
		}

		return date;

	}
	
	public static Date setDataSql(java.util.Date data) throws Exception {
	 java.sql.Date  sqldate = null;
	 SimpleDateFormat fmt = new SimpleDateFormat ("yyyy-MM-dd"); 
	 String datautil =  fmt.format(data); 
	 
     sqldate = java.sql.Date.valueOf(datautil); 
	 return sqldate;
	}
	
	public static String setDataBr(java.sql.Date data) throws Exception {
		
		SimpleDateFormat fmt = new SimpleDateFormat ("dd-MM-yyyy"); 
		 String datautil =  fmt.format(data); 
		 
	     
		 return datautil;
		}
	
	
	public static Time setTimeSql(java.util.Date data) throws Exception {
		 java.sql.Time sqldate = null;
		 SimpleDateFormat fmt = new SimpleDateFormat ("hh:mm:ss"); 
		 String datautil =  fmt.format(data); 
		 
	     sqldate = java.sql.Time.valueOf(datautil); 
		 return sqldate;
		}
}
